{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "74588950-eb05-48bc-aac4-b699de0628e2",
   "metadata": {},
   "source": [
    "## 一切皆对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ed98d9cd-6524-43eb-9b9a-02c58dc7feb8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10, 20, 30, 40]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = [10, 20, 30]\n",
    "\n",
    "s.append(40)\n",
    "\n",
    "s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "741527ce-f1ad-4708-995d-655810fca463",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "bfaa387c-ae7a-4f02-8b71-e42dfd9191e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[10, 20, 30, 40, 100]"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s + [100]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f8e2d767-4eb6-41b2-82d8-c744d6b7d646",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "964041f6-5ba5-4cdb-9c8f-6ab57783ebc1",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "1 + 2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "899ab842-8a58-41fa-b467-37b937124b1d",
   "metadata": {},
   "source": [
    "上面是数学表达的写法，表达第一个数与第二个数相加。\n",
    "\n",
    "下面是从面向对象的角度，调用对象1的方法`__add__(2)`，加上作为参数值对象`2`，产生新的对象`3`："
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "8362430f-8684-44a3-ac7e-926e963b0911",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(1).__add__(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "437bd880-61b8-45cd-b4d8-c6c8929dac5e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6ca55eb1-f5b7-412e-aba6-104c6d129d2f",
   "metadata": {},
   "source": [
    "使用函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "58d97dd3-e774-494b-972e-a266a11059b8",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s = \"abcdef\"\n",
    "\n",
    "len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "d000872a-d129-4788-af1e-8c8ad98cdace",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "6"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s.__len__()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
